import VUE from 'vue'
import VUEX from 'vuex'
import createPersistedState from 'vuex-persistedstate'

VUE.use(VUEX)

const state = {
  isPractice: false, //练习模式标志
  flag: false, //菜单栏左右滑动标志
  userInfo: {},
  menu: [{
      index: '1',
      title: '就业管理',
      icon: 'icon-kechengbiao',
      content:[{item2:'毕业去向',path:'/Directions'},{item3:'岗位申请记录',path:'/ApplyRecord'}],
    },
    {
      index: '2',
      title: '求职信息',
      icon: 'icon-tiku',
      content:[{item1:'招聘会活动',path:'/career'},{item1:'近期宣讲会',path:'/careerTalk'}],
    },
    {
      index: '3',
      title: '就业服务' ,
      icon: 'icon-performance',
      content:[{item1:'职业测评',path:'/careerTest'},],
    },
    {
      index: '4',
      title: '个人中心',
      icon: 'icon-role',
      content:[{item1:'个人信息',path:'/PersonalManage'},{item2: '编辑信息',path: '/updateInfo'},{item3: '修改密码',path: '/updatePwd'}],
    },
  ],
  adminMenu:[{
    index:'1',
    title:'用户管理',
    icon:'icon-Userselect',
    content:[
      {item1: '学生信息',path: '/userManage'}]
  },{
    index: '2',
    title: '就业管理',
    icon: 'icon-tiku',
    content: [{ item1:'学生就业信息',path: '/careerInfo'},{item2: '宣讲会',path: '/careerTalkManage'},{item3:'招聘会',path: '/interviewManage'}]
  },{
    index: '3',
    title: '数据分析',
    icon: 'icon-performance',
    content: [{ item1:'就业率',path: '/employmentRate'},{item2: '历年数据对比',path: '/compare'}]
  }],
  roles:null,
  toggle:true
}
const mutations = {
  setRoleAsUser(){
    state.roles = 1
  },
  setRoleAsAdmin(){
    state.roles = 0
  },
  setUser(state, user) {
    state.userInfo = user;
  },
  logout(state) {
    state.userInfo = null;
  },
  toggle(){
    state.toggle = !state.toggle
  }
}
const getters = {

}
const actions = {

}

export default new VUEX.Store({
  state,
  mutations,
  getters,
  actions,
  plugins:[
    createPersistedState({
      storage:window.sessionStorage,
      // reducer(val){
      //   return{
      //     roles:val.roles,
      //     userInfo:val.userInfo
      //   }
      // }
    })
  ]
  // store
})
